import { getdetail } from "../../utils/api";

const mallDetail = {
  state() {
    return {
      banners: [],
      title: "",
      price: "",
      sale: "",
      detailimg: [],
      space: [],
      num: "",
    };
  },
  mutations: {
    getdetailapi(state, payload) {
      state.banners = payload.data.banners;
      state.title = payload.data.title;
      state.price = payload.data.price;
      state.sale = payload.data.sale;
      state.detailimg = payload.data.details;
      state.space = payload.data.space;
    },
    change(state, payload) {
      state.num = payload.name;
    },
  },
  actions: {
    async getdetailapi({ commit }, payload) {
      const res = await getdetail({ id: payload.id });
      commit("getdetailapi", { data: res.result[0] });
    },
  },
};
export default mallDetail;
